// https://nuxt.com/docs/api/configuration/nuxt-config
import tailwindcss from "@tailwindcss/vite";

export default defineNuxtConfig({
  compatibilityDate: '2025-07-15',
  devtools: { enabled: true },  
  css: ['~/assets/css/main.css'],//这些样式表将被内联到 Nuxt 渲染的 HTML 中，作为全局注入并出现在所有页面中
  vite: {
    plugins: [
      tailwindcss(),
    ],
  },
  app: {
    head: {
      // link: [{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css' }],
    },
    pageTransition: { name: 'page', mode: 'out-in' },
    layoutTransition: { name: 'layout', mode: 'out-in' },
  },
  modules: [
    // '@nuxt/ui',
    // '@nuxtjs/tailwindcss',
  ],
  // pages: true // 启用基于文件的路由
  $production: {
    routeRules: {
      '/**': { isr: true },
    },
  },
  $development: {
    //
  },
  $env: {
    staging: {
      //
    },
  },
  runtimeConfig: {
    // The private keys which are only available server-side
    // apiSecret: '123',
    // // Keys within public are also exposed client-side
    // public: {
    //   apiBase: '/api',
    // },
    // 私有配置（仅服务端可用）
    apiSecret: process.env.API_SECRET,
    
    // 公共配置（客户端和服务端都可用）
    public: {
      API_URL: process.env.API_URL || 'http://localhost:3001',
      // 或者使用小写命名
      apiUrl: process.env.API_URL || 'http://localhost:3001',
    }
  },
  nitro: {
    devProxy: {
      '/api': {
        target: process.env.API_URL || 'http://localhost:3001',
        changeOrigin: true,
        prependPath: true,
      },
      '/backend': {
        target: 'https://your-backend-api.com',
        changeOrigin: true,
        prependPath: true
      }
    },
    prerender: {
      crawlLinks: true,
      routes: ['/robots.txt'],
    },
  },
})
